<?php

use Illuminate\Support\Facades\Artisan;
/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
|
*/
// 登录注册相关
Auth::routes();
// 首页
Route::get('/', function () {
    return view('home.welcome');
});
// 用户页
Route::group(['namespace' => 'Home', 'middleware' => ['auth:web']], function () {
    Route::get('/home', 'IndexController@index')->name('home');
    Route::group(['prefix' => 'notebook'], function () {
         Route::get('manage', 'NotebookController@manage')->name('notebook.manage');
        Route::get('create','NotebookController@create')->name('notebook.create');
        Route::post('store','NotebookController@store')->name('notebook.store');
    });
    Route::group(['prefix' => 'note'], function () {
        Route::get('manage', 'NoteController@manage')->name('note.manage');
        Route::get('create','NoteController@create')->name('note.create');
        Route::post('store','NoteController@store')->name('note.store');
    });
});
// 管理页
Route::group(['namespace' => 'Admin', 'prefix' => 'admin', 'middleware' => ['auth:web', 'checkAdmin']], function () {
    Route::get('/', 'IndexController@index')->name('dashboard');
});
// 清理缓存（测试）
Route::get('/clear',function(){
    Artisan::call('cache:clear');
    return redirect()->route('home');
});
